mysterious-toddler-20573
05/28/2023, 10:13 PMhttps://cdn.discordapp.com/attachments/725789747212976259/1112503927351545946/image.png▾
mysterious-toddler-20573
05/28/2023, 10:16 PMapplescript
on input debounced at 200ms 
  add .btn-disabled to the #submitButton
  for field in <[data-initalValue]/> in me
    if the field's @data-initialValue is not equal to the field's value then
      remove .btn-disabled from the #submitButton then exitmysterious-toddler-20573
05/28/2023, 10:17 PMbrash-house-85887
05/28/2023, 10:17 PMmysterious-toddler-20573
05/28/2023, 10:17 PMmysterious-toddler-20573
05/28/2023, 10:17 PM< ... />mysterious-toddler-20573
05/28/2023, 10:18 PMbrash-house-85887
05/28/2023, 10:20 PMis not equal to theis not themysterious-toddler-20573
05/28/2023, 10:28 PMmysterious-toddler-20573
05/28/2023, 10:34 PMmysterious-toddler-20573
05/28/2023, 10:34 PMbrash-house-85887
05/28/2023, 10:36 PMmysterious-toddler-20573
05/28/2023, 10:40 PMbrash-house-85887
05/28/2023, 10:49 PMgreat-cartoon-12331
05/28/2023, 11:08 PMfreezing-waitress-26396
05/28/2023, 11:13 PMbehavior validateForm
    on click or change or input
        set validated to my.checkValidity()
        if validated tell the first <button[type='submit']/> in me remove [@disabled] end
        else tell the first <button[type='submit']/> in me add [@disabled] end
    end
endfreezing-waitress-26396
05/28/2023, 11:14 PMbrash-house-85887
05/28/2023, 11:16 PMfreezing-waitress-26396
05/28/2023, 11:23 PMfreezing-waitress-26396
05/28/2023, 11:23 PMvalidateFormmysterious-toddler-20573
05/28/2023, 11:28 PMhigh-iron-12893
05/28/2023, 11:40 PMhx-triggerhidden.bs.modalgray-morning-3453
05/29/2023, 12:14 AMfunction hasFormChanged(form) {
                // Get all controls 
                const controls = form.querySelectorAll("input, textarea, select");
                // Initialize flag
                let changed = false;
                // Loop through
                controls.forEach(control => {
                    // Ignore controls that are disabled or readonly
                    if (control.disabled || control.readOnly) {
                    return;
                    }
                    if (control.type === "checkbox" || control.type === "radio") {
                    // For checkboxes and radio buttons, compare checked state to defaultChecked state
                    if (control.checked !== control.defaultChecked) {
                        changed = true;
                    }
                    } else if (control.tagName === "SELECT") {
                    // For select elements, compare selected options to defaultSelected options
                    const selectedOptions = Array.from(control.options).filter(option => option.selected);
                    const defaultSelectedOptions = Array.from(control.options).filter(option => option.defaultSelected);
                    if (selectedOptions.length !== defaultSelectedOptions.length) {
                        changed = true;
                    } else {
                        for (let i = 0; i < selectedOptions.length; i++) {
                        if (selectedOptions[i] !== defaultSelectedOptions[i]) {
                            changed = true;
                            break;
                        }
                        }
                    }
                    } else {
                    // For all other form controls, compare current value to defaultValue
                    if (control.value !== control.defaultValue) {
                        changed = true;
                    }
                    }
                });
                return changed;
            }gray-morning-3453
05/29/2023, 12:15 AMgray-morning-3453
05/29/2023, 12:16 AMswift-spring-80795
05/29/2023, 2:22 AMgreat-cartoon-12331
05/29/2023, 2:23 AMswift-spring-80795
05/29/2023, 2:36 AMgreat-cartoon-12331
05/29/2023, 2:37 AM